<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>发射任务列表</title>
    <link rel="stylesheet" th:href="@{../../component/pear/css/pear.css}"/>
    <style>
        .inputstyle {
            width: 144px;
            height: 41px;
            cursor: pointer;
            font-size: 30px;
            outline: medium none;
            position: absolute;
            filter: alpha(opacity=0);
            -moz-opacity: 0;
            opacity: 0;
            left: 0px;
            top: 0px;
        }
    </style>
</head>

<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <div class="col-sm-13 search-collapse">
            <form class="layui-form" id="formId">
                <div class="layui-form-item">
                    <label class="layui-form-label">台站ID：</label>
                    <div class="layui-input-inline">
                        <input class="layui-input"  name="stationCode" placeholder="请输入台站ID" type="text"/>
                    </div>
                    <label class="layui-form-label" style="width: 7%">发射机ID：</label>
                    <div class="layui-input-inline">
                        <input class="layui-input" name="transCode" placeholder="请输入发射机ID" type="text"/>
                    </div>
                    <label class="layui-form-label" style="width: 7%">任务开始时间：</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="sendDateTime"  name="sendDateTime"  placeholder="yyyy-MM-dd HH:mm:ss" >
                    </div>
                    <button class="pear-btn pear-btn-md pear-btn-primary" lay-filter="myTable-query" lay-submit>
                        <i class="layui-icon layui-icon-search"></i>
                        查询
                    </button>
                    <button class="pear-btn pear-btn-md" type="reset">
                        <i class="layui-icon layui-icon-refresh"></i>
                        重置
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
<div class="layui-card">
    <div class="layui-card-body">
        <table id="myTable" lay-filter="myTable"></table>
    </div>
</div>

<script th:src="@{../../component/layui/layui.js}"></script>
<script th:src="@{../../component/pear/pear.js}"></script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="detail">详情</a>
</script>
<script>
    let upload;
    layui.use(['table', 'form', 'jquery', 'popup','laydate','element', 'util','layer','upload'], function () {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let popup = layui.popup;
        let laydate = layui.laydate;
        upload = layui.upload;
        let MODULE_PATH = "/system/task/";

        laydate.render({
            elem: '#sendDateTime',
            type: 'datetime',
            theme: 'grid',
            // value: getRecentDay(0),
        });
        setInterval(function () {
            table.reloadData('myTable');
        }, 10000);

        form.on('submit(myTable-query)', function (data) {
            table.reload('myTable', {where: data.field})
            return false;
        });

        let cols = [
            [
                {
                    title: '台站ID',
                    field: 'stationCode',
                    align: 'center'
                },
                {
                    title: '发射机ID',
                    field: 'transCode',
                    align: 'center'
                },
                {
                    title: '通道号',
                    field: 'taskId',
                    align: 'center',
                    sort: true
                },
                {
                    title: '开始时间',
                    field: 'sendDateTime',
                    align: 'center',
                    sort: true
                },
                {
                    title: '结束时间',
                    field: 'sendDateEndTime',
                    align: 'center',
                    sort: true
                },
                {
                    title: '工作频率(Hz,取值:3200~26100)',
                    field: 'channelFreq',
                    align: 'center',
                    templet: '#table-Register',
                    sort: true
                },
                {
                    title: '输出功率(W, 取值:0~+200)',
                    field: 'channelEqualization',
                    align: 'center'
                },
                {
                    title: '操作',
                    toolbar: '#barDemo',
                    width: '15%'
                }
            ]
        ]

        table.render({
            elem: '#myTable',
            url: MODULE_PATH +'data',
            page: true,
            cols: cols,
            skin: 'line',
            toolbar: '#power-toolbar',
            defaultToolbar: [],
            cellMinWidth: 'auto',
            done: function (res, curr, count) {
            }
        });


        table.on('tool(myTable)', function(obj) {
            var rowIndex = $(obj.tr).attr("data-index");
            var data = obj.data;
            json = JSON.stringify(data);
            switch(obj.event) {
                case 'detail':
                    layer.open({
                        type: 2,
                        title: "节目详情页面",
                        area: ['100%', '100%'],
                        fix: false,
                        maxmin: true,
                        shadeClose: true,
                        shade: 0.4,
                        skin: 'layui-layer-rim',
                        content: ["/system/view/getTaskDetail", "no"],
                        success: function (layero, index) {
                            var body = layer.getChildFrame('body', index);
                            body.find("[name='stationCode']").val(data.stationCode);
                            body.find("[name='transCode']").val(data.transCode);
                            body.find("[name='taskId']").val(data.taskId);
                            body.find("[name='sendDateTime']").val(data.sendDateTime);
                            body.find("[name='sendDateEndTime']").val(data.sendDateEndTime);
                            body.find("[name='operType']").val(data.operType);
                            body.find("[name='channelFreq']").val(data.channelFreq);
                            body.find("[name='channelRfChState']").val(data.channelRfChState);
                            body.find("[name='channelTimeSlot']").val(data.channelTimeSlot);
                            body.find("[name='channelEqualization']").val(data.channelEqualization);
                            body.find("[name='channelRfChMod']").val(data.channelRfChMod);
                            body.find("[name='channelRfChBand']").val(data.channelRfChBand);
                            body.find("[name='channelRfChASource']").val(data.channelRfChASource);
                            body.find("[name='channelRfChAUrl']").val(data.channelRfChAUrl);
                            body.find("[name='sendTime']").val(data.sendTime);
                        }
                    });
                    break;
            }
        })
    })

</script>
</body>

</html>
